package com.tender.facade;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class StockFacadeSentinelFallBackFactory implements FallbackFactory<StockFacadeSentinelApi> {

    @Value("${server.port}")
    private String port;

    @Override
    public StockFacadeSentinelApi create(Throwable cause) {
        return new StockFacadeSentinelApi() {
            @Override
            public String deduceStockByOrderNo(String orderNo) {
                return "方法：deduceStockByOrderNo " + " 端口：" + port + " 触发服务降级";
            }

            @Override
            public String checkStockInfoByNo(String stockNo) {
                return "方法：checkStockInfoByNo " + " 端口：" + port + " 触发服务降级";
            }
        };
    }
}
